﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 二维数组遍历
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int[,] arr ={
                {1, 2, 3 },
                {4, 5, 6 },
                {7, 8, 9 },
            };
            //GetLength可以获取到当前数组的行/列的数量

            //0:代表行

            //1:代表列

            //Console.WriteLine(arr.GetLength(0));

            for (int i = 0;i < arr.GetLength(0);i++)
            {
                for(int j = 0; j < arr.GetLength(1);j++)
                {
                    Console.WriteLine(arr[i, j]);
                }
            }

            foreach (int v in arr)
            {
                Console.WriteLine(v);
            }

            Console.Read();
        }
    }
}
